from flask import Flask, jsonify, request,helpers,scaffold
from flask_cors import CORS
# helpers._endpoint_from_view_func = scaffold._endpoint_from_view_func
# from flask import Blueprint
# from flask_restplus import Api
# rest_api = Api()

# api_blueprint = Blueprint("open_api", __name__, url_prefix="/api")
# api = Api(api_blueprint, version="1.0",
#           prefix="/v1", title="OpenApi", description="The Open Api Service")



# app.register_blueprint(api_blueprint)

def regist_api(app):
    from m1 import bp as m1_bp
    from m2 import bp as m2_bp
    
    app.register_blueprint(m1_bp)
    app.register_blueprint(m2_bp)

def create_app(ini_config:dict=None):
    app = Flask(__name__,instance_relative_config=True)
    # 跨域
    CORS(app, supports_credentials=True)
    # rest_api.init_app(app,version='1.0',title='api',description='API接口')
    # 文件
    regist_api(app)
    
    return app

app = create_app()